<?php
namespace Topxia\WebBundle\Controller;

use Topxia\Common\Paginator;
use Topxia\Common\ArrayToolkit;
use Topxia\Service\Util\EdusohoLiveClient;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class KukeController extends BaseController
{
    
    public function baomingAction(Request $request)
    {
		$is_post = !empty($_POST) ? true : false;
		if($is_post){
			$fields = $request->request->get('profile');
			if($this->getBaomingService()->checkShenfenzheng($fields['shenfenzheng'])){
				return $this->render('TopxiaWebBundle:Kuke:baoming.html.twig', array(
					'status'=>'请不要重复提交'
				));
			}
			$res = $this->getBaomingService()->save($fields);
			if($res){
				return $this->render('TopxiaWebBundle:Kuke:baoming.html.twig', array(
					'status'=>'提交成功'
				));
			}else{
				return $this->render('TopxiaWebBundle:Kuke:baoming.html.twig', array(
					'status'=>'提交失败'
				));
			}
		}
		
        return $this->render('TopxiaWebBundle:Kuke:baoming.html.twig', array(
			'status'=>''
		));
    }
	
    public function baominglistAction(Request $request)
    {
		var_dump($this->getBaomingService()->getBaomingList());die;
    }
	
	public function baomingcheckAction(Request $request){
		$sfz = $request->request->get('shenfenzheng');
		$is_have = $this->getBaomingService()->checkShenfenzheng($sfz);
		if($is_have)
			return new Response(json_encode(array('text'=>'身份证重复','status'=>1)));
		else
			return new Response(json_encode(array('text'=>'','status'=>0)));
	}

    protected function getBaomingService()
    {
        return $this->getServiceKernel()->createService('Kuke.BaomingService');
    }
}
